/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package view;

import control.MStockMidlet;
import javax.microedition.lcdui.Display;
import listener.Command;
import listener.ICommandListener;
import model.ErrorMessage;
import ui.Detail;
import ui.TextItem;

/**
 *
 * @author kien.tran
 */
public class InfoForm extends AForm implements ICommandListener {

    private Detail detail;
    private String title;
    private String content;

    public InfoForm() {
    }

    public InfoForm(MStockMidlet control, Display display, int branch, int option) {
        super(control, display);
        this.branch = branch;
        this.option = option;
    }

    protected void initData() {
        lang = new String[]{"Thông báo", "Dữ liệu đã được cập nhật."};

        recycle = control.getRecycle();

        if (branch == State.CONFIG) {
            if (option == State.DATA) {
                title = lang[0];
                content = lang[1];
                icon = control.getIcons()[7];
            }
        }

    }

    protected void initGui() {
        detail = new Detail(display, control, title, background, icon);
        ok = new Command("Ok", Command.OK);
        detail.setSelectCommand(ok);
        detail.setCommandListener(this);

        showData();
    }

    protected void loadData() {
    }

    protected void showData() {
        this.detail.addItem(new TextItem("-1", "", content));
        this.detail.show();
    }

    protected void showError(ErrorMessage error) {
    }

    public void commandAction(Command command) {
        if (command == ok) {
            if (branch == State.CONFIG) {
                if (option == State.DATA) {
                    control.back(1);
                }
            }
        }
    }
}
